﻿using ChiWalker.Dynamics;
using ChiWalker.Helpers;
using ChiWalker.Spell;
using ChiWalker.Utilities;
using Styx;
using Styx.TreeSharp;

namespace ChiWalker.Routines.Paladin
{
    internal class Retribution
    {
        [Behavior(BehaviorType.Combat | BehaviorType.Pull)]
        [Spec(WoWSpec.PaladinRetribution)]
        [Class(WoWClass.Paladin)]
        public static Composite PaladinRetribution()
        {
            return new PrioritySelector(
                Safers.EnsureTarget(),
                WaitFor.WaitForCast(),
                Movement.MoveToLoS(ret => StyxWoW.Me.CurrentTarget),
                Movement.FaceMyTarget(),
                new CastOnSelf(Spell.SealofTruth,
                    ret =>
                        !StyxWoW.Me.HasAura(31801) &&
                        Clusters.GetClusterCount(StyxWoW.Me, Clusters.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f) <
                        4),
                new CastOnSelf(Spell.SealofRighteousness,
                    ret =>
                        !StyxWoW.Me.HasAura("Seal of Righteousness") &&
                        Clusters.GetClusterCount(StyxWoW.Me, Clusters.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f) >=
                        4),
                new CastOnMyTarget(Spell.Rebuke, ret => StyxWoW.Me.CurrentTarget.CanInterruptCurrentSpellCast),
                new CastOnSelf(Spell.SacredShield, ret => !StyxWoW.Me.HasMyAura("Sacred Shield")),
                new CastOnSelf(Spell.Inquisition,
                    ret =>
                        StyxWoW.Me.GetAuraTimeLeft("Inquisition", true).TotalSeconds <= 3 &&
                        StyxWoW.Me.CurrentHolyPower >= 3),
                new CastOnMyTarget(Spell.DivineStorm,
                    ret =>
                        StyxWoW.Me.CurrentHolyPower >= 3 &&
                        Clusters.GetClusterCount(StyxWoW.Me, Clusters.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f) >=
                        2),
                new CastOnMyTarget(Spell.TemplarsVerdict, ret => StyxWoW.Me.CurrentHolyPower == 5),
                new CastOnMyTarget(Spell.ExecutionSentence),
                new CastOnMyTarget(Spell.HammerofWrath),
                new CastOnMyTarget(Spell.HammeroftheRighteous,
                    ret =>
                        Clusters.GetClusterCount(StyxWoW.Me, Clusters.NearbyUnitsInCombatWithMe, ClusterType.Radius, 8f) >=
                        2),
                new CastOnMyTarget(Spell.CrusaderStrike),
                new CastOnMyTarget(Spell.Judgment),
                new CastOnMyTarget(Spell.Exorcism),
                new CastOnMyTarget(Spell.TemplarsVerdict, ret => StyxWoW.Me.CurrentHolyPower >= 3),
                Movement.MoveToUnit(ret => StyxWoW.Me.CurrentTarget)
                );
        }
    }
}